<template>
  <edit-layout ref="layout" :page="page" :form="form" @invoke="invoke">
    <el-form ref="form" :model="form" :size="page.settings.formSize" :label-width="page.settings.labelWidth">
      <el-divider content-position="left">基础资料</el-divider>
      <el-form-item label="名称" prop="name" :rules="page.rules.def">
        <el-input v-model="form.name" class="col" placeholder="请输入名称" />
      </el-form-item>
      <el-form-item
        label="编码"
        prop="no"
        :rules="{
          validator:page.rules.remote,
          url:page.router.remoteUrl+'/existNo/',
          params:{no:form.no,id:form.id
          }, trigger: 'blur'}"
      >
        <el-input
          v-model="form.no"
          :disabled="form.id!=null"
          class="col"
          placeholder="助记词编码"
        />
      </el-form-item>
      <el-form-item>
        <duty-users v-model="form.salesmanId" lable="业务员" :duty-id="$store.state.settings.wmsConf.purchase.dutyId[1]" @change="managerChange" />
      </el-form-item>
      <el-form-item label="地区" prop="areaIds" :rules="page.rules.def">
        <form-area v-model="form.areaIds" class="col-3" :area="form.area" :level="3" @set-area="setArea" />
      </el-form-item>
      <el-form-item label="详细地址" prop="address">
        <el-input v-model="form.address" class="col-6" placeholder="请输入详细地址" />
      </el-form-item>
      <el-form-item label="优先级" prop="isSpecial">
        <el-radio-group v-model="form.isSpecial">
          <el-radio :label="0">普通</el-radio>
          <el-radio :label="1">重要</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="备注" prop="remark">
        <el-input v-model="form.remark" class="col-6" type="textarea" :rows="2" placeholder="请输入备注" />
      </el-form-item>
      <el-divider content-position="left">联系方式</el-divider>

      <el-form-item label="负责人" prop="linkman" :rules="page.rules.zh">
        <el-input v-model="form.linkman" class="col" placeholder="请输入负责人" />
      </el-form-item>
      <el-form-item label="手机号" prop="mobile" :rules="page.rules.phone">
        <el-input v-model="form.mobile" class="col" placeholder="请输入手机号" />
      </el-form-item>
      <el-form-item label="邮箱" prop="email">
        <el-input v-model="form.email" class="col" placeholder="请输入邮箱" />
      </el-form-item>
      <el-form-item label="QQ|微信" prop="qq">
        <el-input v-model="form.qq" class="col" placeholder="请输入QQ|微信" />
      </el-form-item>
      <div v-if="form.id!=null">
        <el-divider content-position="left">业务统计</el-divider>
        <el-form-item>
          <div class="col-6">
            <el-row type="flex" class="row-bg">
              <el-col :span="6">供货总额：{{ form.sales }}</el-col>
              <el-col :span="6">供货次数：{{ form.orderCount }}</el-col>
              <el-col :span="6">供货总重：{{ form.weight }}</el-col>
            </el-row>
          </div>
        </el-form-item>
      </div>
    </el-form>
  </edit-layout>
</template>
<script>
import adminSupport from 'lola-admin-support-el'

export default {
  name: 'SupplierManageEdit',
  mixins: [adminSupport.mixins.edit],
  data() {
    return {
      name: 'SupplierManage',
      salesmanUrl: ''
    }
  },
  mounted() {
    this.page.tip = '请认真填写供应商相关信息'
    this.init()// 初始化
  },
  methods: {
    init() {
      console.log(this.upload.img)
      this.page.ids.push(this.$route.params.no)// 页面主参数赋值
      this.salesmanUrl = this.service.conf.api.get('portal').url + '/api/user/findAll/duty/' + this.$store.state.settings.wmsConf.purchase.dutyId[1]
      this.loadData()// 加载数据
    },
    appendForm() {

    }, buildForm() {
      return true
    },
    setArea(val) {
      // alert(val);
      this.form.area = val
    },
    managerChange(manager) {
      console.log(manager)
    }
  }
}
</script>
